<?php
session_start();
if(isset($_SESSION['admin'])){
    $admin=$_SESSION['admin'];

    echo "<script>window.location.href='html/index.php';</script>";

}
else{


}



?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="shortcut icon" href="https://wangjibu.top/statics/images/icon/logo1.ico">
    <title>超级管理员登录</title>
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="static/css/xadmin.css">
    <script type="text/javascript" src="static/js/jquery-3.3.1.min.js"></script>
    <script src="static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="static/js/xadmin.js"></script>
    <style>
        body{
            background-color: transparent;
        }

    </style>

</head>
<body class="login-bg">

<div class="login layui-anim layui-anim-up">
    <div class="message">超级管理员登录</div>
    <div id="darkbannerwrap"></div>

    <form method="post" class="layui-form" >
        <input  name="username" id="username" lay-verify="required" placeholder="请输入你的帐号" autocomplete="off" class="layui-input" >
        <hr class="hr15">
        <input  name="password" id="password"  lay-verify="required" placeholder="请输入你的密码" autocomplete="off" type="password" class="layui-input">
        <hr class="hr15">
        <input value="登录" onclick="login()"  style="width:100%;" type="button">
        <hr class="hr20" >
    </form>
</div>

<script>
    $(function  () {
        layui.use('form', function(){
            var form = layui.form;


            //监听提交
            form.on('submit(login)', function(data){
                // alert(888)
                layer.msg(JSON.stringify(data.field),function(){
                    location.href='index.html'
                });
                return false;
            });
        });
    })


</script>
<script>
    function login() {

        var
        var user_name = $('input[name="username"]'),
            user_pwd = $('input[name="password"]');
        if (user_name.val() === '') {
            layer.msg ('你的账号还未填写');
            return false;


        }
        if (user_pwd.val() === '') {
            layer.msg('你的密码还未填写');
            return false;
        }
        else {
            $user = user_name.val();
            $pass = user_pwd.val();
            $.ajax({
                type: 'post',
                cache: 'false',
                url: 'php/admin/loginU.php',
                data: {
                    "user": $user,
                    "pass": $pass,
                },
                dataType: 'Json',
                success: function (dat) {
                    layer.msg(dat.message);
                    if(dat.message==="登陆成功") {
                        var time = setInterval(showTime, 1000);
                        var second = 0;

                        function showTime() {
                            if (second == 0) {
                                window.location.href = "html/index.php?user="+$user;
                                clearInterval(time);

                            }
                            layer.msg("即将跳转页面" + second + "秒");
                            second--;
                        }
                    }


                },
                error: function (dat) {
                    layer.msg("登陆失败，请检查网络是否正常");
                }


            })


        }







    }
    function show() {

        layer.open({
            type: 1,
            skin: 'layui-layer-lan',
            anim: 4 ,
            shadeClose: true, //开启遮罩关闭
            content: '<img style="width:300px" src="https://wangjibu.top/img/wei.png"/>'
        });
    }

</script>
</body>
</html>